package com.sskj.api.controller.admin;

import com.sskj.api.annotation.OperationLog;
import com.sskj.api.service.ISRSService;
import com.sskj.api.vo.srs.ClientInfo;
import com.sskj.api.vo.srs.StreamInfo;
import com.sskj.api.vo.srs.Summaries;
import com.sskj.api.vo.srs.VhostInfo;
import com.sskj.common.util.ApiResponseUtil;
import com.sskj.common.vo.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/srs")
@Tag(name = "SRS流媒体服务")
public class SRSController {

    @Autowired
    private ISRSService srsService;

    @OperationLog(module = "SRS流媒体服务", action = "概览")
    @Operation(summary = "概览")
    @GetMapping("summaries")
    public ApiResponse<Summaries> summaries() {
        Summaries summaries = srsService.summaries();

        return ApiResponseUtil.success(summaries);
    }

    @OperationLog(module = "SRS流媒体服务", action = "客户端")
    @Operation(summary = "客户端")
    @GetMapping("clients")
    public ApiResponse<List<ClientInfo>> clients() {
        List<ClientInfo> clients = srsService.clients();

        return ApiResponseUtil.success(clients);
    }

    @OperationLog(module = "SRS流媒体服务", action = "视频流")
    @Operation(summary = "视频流")
    @GetMapping("streams")
    public ApiResponse<List<StreamInfo>> streams() {
        List<StreamInfo> streamInfos = srsService.streams();

        return ApiResponseUtil.success(streamInfos);
    }

    @OperationLog(module = "SRS流媒体服务", action = "视频流")
    @Operation(summary = "视频流")
    @GetMapping("vhosts")
    public ApiResponse<List<VhostInfo>> vhosts() {
        List<VhostInfo> vhostInfos = srsService.vhosts();

        return ApiResponseUtil.success(vhostInfos);
    }
}
